import axios from 'axios'

const HTTP_BASE_URL = 'http://127.0.0.1:8080'

function request(config) {
	// 封装axios
	const instance = axios.create({
		baseURL: HTTP_BASE_URL,
		timeout: 5000,
		data: config.data,
		headers: {
			'GET': {
				// 设置默认请求头，当需要特殊请求头时，将其作为参数传入，即可覆盖此处的默认参数
				"Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
			},
			'POST': {
				// 设置默认请求头，当需要特殊请求头时，将其作为参数传入，即可覆盖此处的默认参数(第三个参数即config)
				// 例如：
				//     services.post(`${base.lkBaseURL}/uploads/singleFileUpload`, file, {
				//       headers: { "Content-Type": "multipart/form-data" }
				//     });
				"Content-Type": "application/json;charset=utf-8"
			}
		}
	})
	// 发送一个真正的请求
	return instance(config);
}

//获取书籍列表
export const getBookList = (params) => {
	return request({
		method: "GET",
		url: "/book/listPage",
		params
	})
}
//书籍添加借阅
export const addBookBorrow = (data) => {
	return request({
		method: "POST",
		url: "/book-borrow/add",
		data
	})
}
//书籍借阅记录列表
export const borrowList = (params) => {
	return request({
		method: "GET",
		url: "/book-borrow/listPage",
		params
	})
}
//书籍归还
export const returnBook = (params) => {
	return request({
		method: "GET",
		url: "/book-borrow/returnBook",
		params
	})
}


//获取座位列表
export const getSeatList = (params) => {
	return request({
		method: "GET",
		url: "/library-seat/listPage",
		params
	})
}

//获取座位预定记录
export const getSeatReserve = (params) => {
	return request({
		method: "GET",
		url: "/library-seat-reserve/listPage",
		params
	})
}

//获取座位预定情况
export const listReserveBySeat = (params) => {
	return request({
		method: "GET",
		url: "/library-seat-reserve/listReserveBySeat",
		params
	})
}

//删除座位预定记录
export const delSeatReserve = (params) => {
	return request({
		method: "GET",
		url: "/library-seat-reserve/delete",
		params
	})
}

//添加座位预定
export const addSeatReserve = (data) => {
	return request({
		method: "POST",
		url: "/library-seat-reserve/add",
		data
	})
}

// 实验室 ------------------------------

//获取器材分页列表
export const qcList = (params) => {
	return request({
		method: "GET",
		url: "/equipment/listPage",
		params
	})
}
//添加器材
export const addQcEquipment = (data) => {
	return request({
		method: "POST",
		url: "/equipment/add",
		data
	})
}

//删除器材
export const delEquipment = (params) => {
	return request({
		method: "GET",
		url: "/equipment/delete",
		params
	})
}
//更新器材
export const updateEquipment = (data) => {
	return request({
		method: "POST",
		url: "/equipment/update",
		data
	})
}

//获取器材损坏记录列表
export const qcDamageList = (params) => {
	return request({
		method: "GET",
		url: "/equipment-damage-report/listPage",
		params
	})
}

//添加器材损坏记录
export const addQcDamage = (data) => {
	return request({
		method: "POST",
		url: "/equipment-damage-report/add",
		data
	})
}

//删除器材损坏记录
export const delDamageEquipment = (params) => {
	return request({
		method: "GET",
		url: "/equipment-damage-report/delete",
		params
	})
}

//修改器材损坏记录
export const editQcDamage = (data) => {
	return request({
		method: "POST",
		url: "/equipment-damage-report/update",
		data
	})
}

//获取器材库存记录列表
export const qcDamageInventory = (params) => {
	return request({
		method: "GET",
		url: "/equipment-inventory-record/listPage",
		params
	})
}

//获取实验室列表
export const laboratoryList = (params) => {
	return request({
		method: "GET",
		url: "/laboratory/listPage",
		params
	})
}

//添加实验室
export const addLaboratory = (data) => {
	return request({
		method: "POST",
		url: "/laboratory/add",
		data
	})
}
//添加实验室
export const updateLaboratory = (data) => {
	return request({
		method: "POST",
		url: "/laboratory/update",
		data
	})
}

//获取实验室预定情况
export const listReserveByLab = (params) => {
	return request({
		method: "GET",
		url: "/laboratory-reserve/listReserveByLab",
		params
	})
}

//添加实验室预定
export const addLabortoryReserve = (data) => {
	return request({
		method: "POST",
		url: "/laboratory-reserve/add",
		data
	})
}

//获取座位预定记录
export const getLabortoryReserve = (params) => {
	return request({
		method: "GET",
		url: "/laboratory-reserve/listPage",
		params
	})
}

//删除座位预定记录
export const delLabortoryReserve = (params) => {
	return request({
		method: "GET",
		url: "/laboratory-reserve/delete",
		params
	})
}